﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="create_key.aspx.cs" Inherits="AnyOffice.general.system.user.create_key" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head id="Head1" runat="server">
    <title>初始化USB KEY</title>
</head>
<body onload="createKey()">
<OBJECT classid="clsid:4CCD4FD7-509F-41AC-92EC-7463C8A62809" id="IA100A" name="IA100A" STYLE="LEFT: 0px; TOP: 0px" width=50 height=20>
<embed width="50" height="20" name="IA100A"></embed>
</OBJECT>
    <form id="form1" runat="server">
    <div id="divMessage"></div>
    <input type='hidden' name='UGuid' value="" id="UGuid" runat="server" />
    </form>
<script language="javascript">
function createKey()
{
    var rtn;	
    try
    {	
        rtn=IA100A.IA100Find();
    }
    catch(e)
    {
        alert("您没有下载并正确安装USB KEY驱动程序");       
        document.getElementById("divMessage").innerHTML="<a href=/lib/usbkey/setup.exe>USB KEY驱动程序下载</a>";
        return;
    }
    	
    if(rtn != 0)
    {
	    alert("您没有插入合法的USB KEY");
	    location="user_dept.aspx?dept_id=<%=ViewState["DeptId"]%>";
	    return;
    }

    var	guid = IA100A.IA100GetGUID();

    rtn = IA100A.IA100CheckSuperPin('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
    if(rtn != 0)
    {
        alert("检查超级密码失败");
	    return;
    }

    rtn = IA100A.IA100SetKey('<%=uKey %>');
    if(rtn == 0)
    {
        //alert("修改用户密钥成功");
    }
    else
    {
        //alert("修改用户密钥失败");
    }

    IA100A.IA100Close();

    document.getElementById("UGuid").value = guid;
    document.form1.submit();
}
</script>

</body>
</html>
